//
//  NoticeAdvertismentTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/7/17.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "NoticeAdvertismentTableViewCell.h"

@implementation NoticeAdvertismentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.backgroundColor = SFM242;
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.detailLabel];
}

-(void)send
{
    self.titleLabel.text = @"新年屯衣季>>";
    NSString * str = @"【新年屯衣系季】新年到了，女孩子就要对自己好一点。送给每天衣橱里都缺一件新衣的你，赶快来屯货啦！";
    CGFloat height = [str boundingRectWithSize:CGSizeMake(WIDTH - 60, MAXFLOAT) withTextFont:font(14)].height;
    if (height > 71) {
        height = 71;
    }
    self.detailLabel.frame = CGRectMake(10, 55, WIDTH - 60, height);
    self.detailLabel.text = str;
}

-(void)sendNoticeAdvertismnetModel:(NoticeAdvertismnetModel *)model
{
    self.titleLabel.text = model.nbTitle;
    self.detailLabel.frame = CGRectMake(15, 55, WIDTH - 60, model.contentHeight);
    self.detailLabel.text = [NSString filterHTML:model.nbContent];
}

-(UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, WIDTH - 30, 131)];
        _bgView.backgroundColor = SFMWhiteColor;
    }
    return _bgView;
}

-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, WIDTH - 60, 50)];
        _titleLabel.font = font(16);
        _titleLabel.textColor = SFM51;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

-(UILabel *)detailLabel
{
    if (_detailLabel == nil) {
        _detailLabel = [[UILabel alloc] init];
        _detailLabel.font = font(14);
        _detailLabel.textColor = SFM153;
        _detailLabel.numberOfLines = 0;
        _detailLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _detailLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
